package com.eims.sls_app.ui.adapter;

import android.content.Context;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import bls.juejin.cn.R;
import com.eims.sls_app.dataaccess.ShowDtMatchOptimize;
import com.eims.sls_app.view.MyListView2;

import java.util.List;
import java.util.Map;

public class OrderInfoJcPlayTypeAdapter_optimize extends BaseAdapter {
	private Context context;
	private List<String> buyContent;
	private List<String> result;
	// private List<String> playtypes;
	// private List<String> playResult;
	// private List<String> playLet;
	// private List<List<Map<String, Object>>> playitems;
	//
	// public OrderInfoJcPlayTypeAdapter_optimize(Context context, List<String>
	// playtypes,
	// List<String> playResult, List<String> playLet,
	// List<List<Map<String, Object>>> playitems) {
	// this.context = context;
	// this.playtypes = playtypes;
	// this.playResult = playResult;
	// this.playLet = playLet;
	// this.playitems = playitems;
	// }
	private List<Integer> markRed;
	private boolean isMy;
	public OrderInfoJcPlayTypeAdapter_optimize(Context context,
			List<String> buyContent, List<String> result, List<Integer> markRed,boolean isMy) {
		this.context = context;
		this.buyContent = buyContent;
		this.result = result;
		this.markRed = markRed;
		this.isMy=isMy;
	}

	@Override
	public int getCount() {
		return buyContent.size();
	}

	@Override
	public Object getItem(int position) {
		return buyContent.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.orderinfo_jc_child_item_optimize, null);
			holder = new ViewHolder();
			holder.child_touzhu_optimize = (TextView) convertView
					.findViewById(R.id.child_touzhu_optimize);
			// holder.orderinfo_jc_child_listview = (MyListView2) convertView
			// .findViewById(R.id.orderinfo_jc_child_listview);
			holder.child_result_optimize = (TextView) convertView
					.findViewById(R.id.child_result_optimize);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		String buyContentString = "";
		if (markRed.get(position) == 1) {
			buyContentString = "<font color=\"#BE0205\">"
					+ buyContent.get(position) + "</font>";
		} else {
			buyContentString = buyContent.get(position);
		}
		// for (int i = 0; i < buyContent.size(); i++) {
		// if (i==(buyContent.size()-1)) {
		// if (markRed.get(i)==0) {
		// buyContentString += buyContent.get(i);
		// }else {
		// buyContentString += "<font color=\"#BE0205\">" +
		// buyContent.get(i)+"</font>";
		// }
		// }else {
		// if (markRed.get(i)==0) {
		// buyContentString += buyContent.get(i)+"<br>";
		// }else {
		// buyContentString += "<font color=\"#BE0205\">" +
		// buyContent.get(i)+"</font><br>";
		// }
		// }
		// }
		if (isMy) {
			holder.child_touzhu_optimize.setText(Html.fromHtml(buyContentString));
		}else {
			holder.child_touzhu_optimize.setText("保密");
		}
		

		String resultsString = "";
		// for (int i = 0; i < result.size(); i++) {
		// if (i==(result.size()-1)) {
		// if (markRed.get(i)==0) {
		// resultsString += result.get(i);
		// }else {
		// resultsString += "<font color=\"#BE0205\">" +
		// result.get(i)+"</font>";
		// }
		// }else {
		// if (markRed.get(i)==0) {
		// resultsString += result.get(i)+"<br>";
		// }else {
		// resultsString += "<font color=\"#BE0205\">" +
		// result.get(i)+"</font><br>";
		// }
		// }
		// }
		if (markRed.get(position) == 1) {
			resultsString = "<font color=\"#BE0205\">" + result.get(position)
					+ "</font>";
		} else {
			resultsString = result.get(position);
		}
		holder.child_result_optimize.setText(Html.fromHtml(resultsString));

		return convertView;
	}

	private class ViewHolder {
		TextView child_touzhu_optimize, child_result_optimize;
		// MyListView2 orderinfo_jc_child_listview;
	}

}
